package com.example.a2032.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a2032.R;
import com.example.a2032.Utils.BleSdk;
import com.example.a2032.Utils.Utils;
import com.example.a2032.activity.dfu.OtaActivity;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WhetherUpdateActivity extends BaseActivity {

    @BindView(R.id.iv_title)
    ImageView ivTitle;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_bg_mode)
    ImageView ivBgMode;
    @BindView(R.id.RadioButton_12)
    ImageView RadioButton12;
    @BindView(R.id.RadioButton_24)
    ImageView RadioButton24;
    @BindView(R.id.tv_timeMode)
    TextView tvTimeMode;
    String filePath;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_whetherupdate);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        filePath=getIntent().getStringExtra(OtaActivity.EXTRA_FILE_PATH);
        tvTitle.setText(R.string.find_newVersion);
    }

    @OnClick(R.id.iv_title)
    public void onViewClicked() {
        finish();
    }

    @OnClick({R.id.RadioButton_12, R.id.RadioButton_24})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.RadioButton_12:
                toFirmwareUpdate();
                break;
            case R.id.RadioButton_24:
                finish();
                break;
        }
    }

    private static final String TAG = "WhetherUpdateActivity";
    private void toFirmwareUpdate() {
        sendData(BleSdk.enterDfu());
        startActivity(OtaActivity.class,OtaActivity.EXTRA_FILE_PATH,filePath);
        finish();
        Log.i(TAG, "onComplete: "+filePath);
    }


}